<?php
$module = 'recruiter';
$baseTheme = 'pepper-grinder';
// Various Servers and Addresses
$baseUrl = Zend_Registry::get('baseServer'); 
// Content Delievery Server i.e. static Files, e.g. CSS, JS, Themes and related images etc
$cdnUrl = Zend_Registry::get('cdnServer');
?>
<!DOCTYPE html>
<html>
<head>

	<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
	<meta http-equiv="Content-Language" content="en-GB" />
	<meta name="description" content="" />
	<meta name="keywords" content="" />
	<meta name="robots" content="index, follow" />
	<link href="<?php echo $cdnUrl?>/css/search.css" type="text/css" rel="stylesheet" />
	<title>RP Global Consultants :: Search Job Seeker</title>
	
<?php
//Jquery UI Theme
$this->jQuery()->addStylesheet($cdnUrl . '/css/themes/' . $baseTheme . '/jquery-ui-1.8.14.custom.css');
// Jquery
$this->jQuery()->setLocalPath($cdnUrl . '/js/jquery-1.5.1.min.js');
// Jquery UI
$this->jQuery()->setUiLocalPath($cdnUrl . '/js/jquery-ui-1.8.14.custom.min.js');

echo $this->headMeta();
echo $this->headTitle();
echo $this->headLink();
echo $this->jQuery()->uiEnable();

echo $this->headMeta();
echo $this->headTitle();
echo $this->headLink();
?>
</head>
<body >
	<div id="container" class="ui-corner-all">
        <div id="header">            
			<div id="company_name">
            	RP Global :: Search
            </div>   <!-- div company_name closes here-->
			
				<div align="right" id="user-span">	
<span>
<?php
if (Zend_Auth::getInstance()->hasIdentity()) {
    
    $authContent = Zend_Auth::getInstance()->getStorage()->read();
    if (is_array($authContent)) {
        $id = $authContent['identity'];
    } else {
        $id = $authContent;
    }
    if ($id != 'anon') {
        $userSession = new Zend_Session_Namespace('userSession');
        $userHome = $userSession->userHome;
        ?>
    <span class="ui-state-default ui-corner-all noprint"><span><a href="<?php echo $baseUrl?>" >&nbsp;Home&nbsp;</a></span></span>
    <span class="ui-state-default ui-corner-all noprint"><span  class="noprint" >&nbsp;Hi!</span> <span id="userName"><a href="<?php echo isset($userHome)?$baseUrl.$userHome:'#';?>" ><?php echo $id;?>&nbsp;</a></span></span>
	<span class="ui-state-default ui-corner-left noprint"><a id="logout"
	href="<?php
        echo $this->url(array('module'=>'default', 'controller' => 'authenticate', 'action' => 'logout'))?>">
&nbsp;Logout&nbsp;<span
	class="ui-icon ui-icon ui-icon-closethick ui-state-default ui-corner-right"
	style="float: right; padding-left: 1px; height:1.26em; margin-left: -1px; margin-top: -1px;"> </span></a></span>
	<?php
    } else {?>
	<span class="ui-state-default ui-corner-all"><a id="login" href="<?php echo $this->url ( array('module'=>'default', 'controller' =>'authenticate', 'action' => 'index'))?>">
		Login</a></span>
<?php }
} else {?>
	<span class="ui-state-default ui-corner-all"><a id="logout" href="<?php echo $this->url ( array('module'=>'default', 'controller' =>'authenticate', 'action' => 'index'))?>">
		Login</a></span>
<?php }?>
</span>

	</div>				
</div>	<!-- div head closes here-->

<hr>

<div id="content" style="clear: both;">
	<h3 align="center" style="color:#654B24;">Search Jobseekers</h3>
	
	<div id="searchBox">
		<form action="javascript:search();">
		
			<div class="ctrlHolder">
	          <label class="lbl" for="industry_id">Industry :</label>
	           <select id="industry_id" name="industry_id" class="selectInput" style="width:200px;">
	           		<option value="0" selected="selected">Select Industry</option>
	           	<?php
	           		$industrySet = $this->industrySet;
	           		foreach ($industrySet as $key=>$industry){
	           			echo "<option value=$industry[industry_id]>";
	           			echo "$industry[industry_name]";
	           			echo "</option>";
	           			echo "\n";
	           		} 
	           	?>
	           </select>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label class="lbl" for="course_type">Education Level :</label>
	           <select id="course_type" name="course_type" class="selectInput"  style="width:200px;" onchange="javascript:getCourses();">
	           		<option value="" selected="selected">Select level</option>
	           		<option value="UG">Under Graduate</option>
	           		<option value="G">Graduate</option>
	         		<option value="PG">Post Graduate</option>
	         		<option value="MP">Master of Philosphy</option>
	         		<option value="PD">Ph.d or Doctrate</option>
	           </select>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label class="lbl" for="course_id">Education Course :</label>
	           <select id="course_id" name="course_id" class="selectInput" disabled="disabled" style="width:200px;" onchange="javascript:getSpecializations();">
	           		<option value="0" selected="selected">Select Course</option>
	           </select>
	        </div>
	        
	        <div class="ctrlHolder">
	          <label class="lbl" for="edu_spec_id">Education Specilization :</label>
	           <select id="edu_spec_id" name="edu_spec_id" class="selectInput" style="width:200px;" disabled="disabled">
	           		<option value="0" selected="selected">Select Specilaization</option>
	           </select>
	        </div>
	        <div id="sliderWrapper" class="ctrlHolder" style="width:100%;">
	        	<label class="lbl" for="exp" style="margin-top:1px;">Experince :</label>
	        		<span style="margin-left:5px; padding-bottom: 5px; padding-top:">
	        			Range between <input id="exp_years_min" name="exp_years_min" value="0" size="1" maxlength="2" style="width:15px; margin-bottom:10px"> 
	        			years to <input id="exp_years_max" name="exp_years_max" value="10" size="1" maxlength="2" style="width:15px; margin-bottom:10px"> years.
	        			You can also select range below.
	        		</span> 
	        	<div id="slider"></div>
	        </div>
	        <div align="center" class="buttonHolder" style="width:100%;">
        		<button type="submit" class="primaryAction">Search</button>
        		<button type="button" class="secondaryAction" onclick="window.location.reload();">Reset</button>
      		</div>
	           
		</form>
	</div>
	<div id="ajaxLoader" align="center">
		<span><img src="<?php echo $cdnUrl?>/images/ajax-loader.gif">&nbsp;Please Wait...</span>
	</div>
	
	<div id="searchResult" class="ui-corner-all">
		<div id="resultData" style="padding:2px;">
			Search result goes here.
		</div>
		
	<!--	<hr>
		
	 <div id="pager"  style="padding:2px;">
			<a href="#">1</a> &nbsp;
			<a href="#">2</a> 
		</div> -->
	</div>
	        	
</div>  <!-- div content closes here-->
      
</div> <!-- div container closes here-->
	
<div id="footer">
	<div id="inside_footer" class="ui-corner-all">
		<div style="float:left;">RP Global Consultants &copy 2011 &middot; All Rights reserved.</div>
			<div style="float:right;">
                <a href="#">Terms</a> &middot;
                <a href="#">Privacy</a> &middot;
                <a href="#">Developer</a> &middot;
                <a href="#">Contact</a> 
            </div>    
	</div> <!-- div inside_footer closes here-->
</div> <!-- div footer closes here-->   
        
	
	<?php
echo $this->headScript()?>

<script type="text/javascript">
var urlSearch = "<?php $baseUrl?>/recruiter/search/fetchprofiles";
var urlGetCourses = "<?php $baseUrl?>/jobseeker/register/getcourses";
var urlGetSpecializations = "<?php $baseUrl?>/jobseeker/register/getspecializations";
var urlSearchPagination =null;

$(document).ready(function() {
	$('#slider').slider({
		range: true,
		min: 0,
		max: 30,
		step: 1,
		values: [ 0, 10 ],
		slide: function( event, ui ) {
			$( "#exp_years_min" ).val( ui.values[ 0 ]);
			$( "#exp_years_max" ).val( ui.values[ 1 ]);
		} 
	}); 
  });

function getCourses(){
	var val = $("#course_type").val();
	$.ajax({
	    url : urlGetCourses,
	    dataType : 'json',
	    type : "post",
	    data: {"course_type":val},
	    success: function(jCourses){
	    	var selectOptionString = '<option value ="0" selected="selected">Select Course</option>';
			$.each(jCourses, function (index, course) {
				selectOptionString += '<option value ="'+course.course_id+'">'+course.course_name+'</option>';
			});
			$('#course_id').removeAttr("disabled");
	        $('#course_id').html(selectOptionString);
	        
	   },
	   error: function(event) {
	        alert(event.responseText);
	   }
	});
	
}

function getSpecializations(){
	var val = $("#course_id").val();
	$.ajax({
	    url : urlGetSpecializations,
	    dataType : 'json',
	    type : "post",
	    data: {"course_id":val},
	    success: function(jSpecs){
	    	var selectOptionString = '<option value ="0" selected="selected">Select Specialization</option>';
			$.each(jSpecs, function (index, edu_spec) {
				selectOptionString += '<option value ="'+edu_spec.edu_spec_id+'">'+edu_spec.edu_spec_name+'</option>';
			});
			$('#edu_spec_id').removeAttr("disabled");
	        $('#edu_spec_id').html(selectOptionString);
	        
	   },
	   error: function(event) {
	        alert(event.responseText);
	   }
	});
	
}

function search() {
	$("#ajaxLoader").css('display','block');
	var cid = $("#course_id").val();
	var iid = $("#industry_id").val();
	var ct = $("#course_type").val();
	var es = $("#edu_spec_id").val();
	var emin = $("#exp_years_min").val();
	var emax = $("#exp_years_max").val();
    $.ajax({
        url : urlSearch,
        type : "get",
        data : {'industry_id':iid, 'course_id':cid, 'course_type':ct, 'edu_spec_id':es, 'emin':emin, 'emax':emax},
        success: function(jData){    
             $("#ajaxLoader").css('display','none');
             var divData= 'Search Result.';
             var count = 1;
             $.each(jData, function (index, data) {
            	 divData += '<div class="resultDataContent">' ;
            	 divData += '<h2><span>'+count+'. </span><a href="#">'+data["name"]+'</a></h2><br />';
            	 divData += '<span><b>Functional Area: </b>'+data["fa_name"]+'</span> <b>&middot;</b>';
            	 divData += '<span><b>Current Location: </b>'+data["curr_location"]+'</span> <b>&middot;</b>';
            	 divData += '<span><b>Experince: </b>'+data["exp_years"]+' years '+data["exp_months"]+' months</span> <b>&middot;</b>';
            	 divData += '<span><b>Mobile_no:</b> '+data["mobile_no"]+'</span> <b>&middot;</b>';
            	 divData += '<span><b>Email:</b> '+data["email"]+'</span>';
            	 divData += '<br />';
            	 divData += '<span><b>Education Level:</b> '+qualification(data["highest_qualification"])+'</span> <b>&middot;</b>';
            	 divData += '<span><b>Course:</b> '+data["course_name"]+'</span> <b>&middot;</b>';
            	 divData += '<span><b>Specialization:</b> '+data["edu_spec_name"]+'</span>';
                 divData +=	'<br />';
                 divData += '<span><b>Skills:</b> '+data["skills"]+'</span>';
                 divData += '</div>';
                 ++count;
  			});	
            $('#resultData').html(divData);	
        },
        error: function(response) {
        	alert('Server Error: '+response);
        	$("#ajaxLoader").css('display','none'); 
        }
    });
}

function qualification(hg){
	switch(hg){
		case 'UG':
			return 'Under Graduate';
		break;
		case 'G':
			return 'Graduate';
		break;	
		case 'PG':
			return 'Post Graduate';
		break;
		case 'MP':
			return 'Master of Philosphy';
		break;
		case 'PD':
			return 'Ph.D of Doctorate';
		break;
	}
}

</script>

</body>
</html>